<template>
  <el-config-provider :locale="elementLocales[locale]">
    <router-view></router-view>
  </el-config-provider>
</template>
<script setup>
import { useI18n } from 'vue-i18n'
import { elementLocales } from './i18n'
const { locale } = useI18n()
locale.value = localStorage.getItem('locale') || 'zh-cn'
// 解决页面重置报错的问题 在vue3中使用element-plus页面重置时报错
const debounce = (fn, delay) => {
  let timer = null;
  return function () {
    let context = this;
    let args = arguments;
    clearTimeout(timer);
    timer = setTimeout(function () {
      fn.apply(context, args);
    }, delay);
  }
}

const _ResizeObserver = window.ResizeObserver;
window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
  constructor(callback) {
    callback = debounce(callback, 16);
    super(callback);
  }
}

</script>

<style lang="less">
html,
body {
  height: 100%;
}
#app {
  height: 100%;
  overflow: hidden;
}
</style>
